package edpool;

public abstract class ExchangerPackage<T>
{
	  final private long threadId;
	  private PackageTypeEnum packageType;
	  private EliminationStateEnum eliminationState = EliminationStateEnum.None;
      private int direction;
      private boolean diffractOnly = false;
      
      protected T value = null;
      protected GlobalExchangeStates<T> globalExchangeStates;
            
	  public ExchangerPackage(PackageTypeEnum packageType, GlobalExchangeStates<T> globalExchangeStates)
	  {
		  	threadId = Thread.currentThread().getId();
		  	this.packageType = packageType;
		  	this.globalExchangeStates = globalExchangeStates;
	  }
	  
	  public void initialize()
	  {	  
		  eliminationState = EliminationStateEnum.None;
		  setDiffractOnly(false);
	  }
	  
    
	  public long getThreadId()
	  {
	        return threadId;
	  }
	
	  public PackageTypeEnum getPackageType()
	  {
		  return packageType;
	  }

	public abstract ExchangerState<T> getWaitingStateObject();
	  
	public abstract ExchangerState<T> getEliminatingStateObject();
	
	public abstract ExchangerState<T> getDiffractingStateObject();
	

	public void setDirection(int direction)
	{
		this.direction = direction;
	}

	public int getDirection()
	{
		return direction;
	}

	public void setEliminationState(EliminationStateEnum eliminationState)
	{
		this.eliminationState = eliminationState;
	}

	public EliminationStateEnum getEliminationState()
	{
		return eliminationState;
	}

	
	public T getValue()
	{
		return value;
	}
	public void setValue(T value)
	{
		this.value = value;
	}

	public void setDiffractOnly(boolean diffractOnly)
	{
		this.diffractOnly = diffractOnly;
	}

	public boolean isDiffractOnly()
	{
		return diffractOnly;
	}      

}
